home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 3.iso / relnotes / shared / howto.data < prev    next >
Text File  |  2002-10-07  |  10KB  |  274 lines

  1. <!-- -*- HTML -*- -->
  2.  
  3. <!-- INCLUDE SIDENAV -->
  4. <!-- NO HIGHLIGHTS -->
  5.  
  6. <!-- BEGIN TITLE -->
  7. <TITLE>Notes on building Open Source software on IRIX</TITLE>
  8. <META NAME="keywords"     CONTENT="SGI IRIX Open Source freeware">
  9. <META NAME="description" CONTENT="Freeware pre-configured, pre-compiled, and inst packaged for SGI IRIX 6.5">
  10. <META NAME="owner"       CONTENT="freeware@sgi.com">
  11. <!-- END TITLE -->
  12.  
  13. <!-- BEGIN CONTENTS -->
  14. <h2>Notes on building Open Source software on IRIX</h2>
  15. <p>
  16. This is a draft document to help people build open source software on
  17. IRIX.  It may be missing some items but having built literally
  18. hundreds of packages on IRIX over the years we're pretty confident
  19. that most of the pitfalls are covered.
  20. <br>
  21.  
  22.  
  23. <h3>General</h3>
  24.  
  25. IRIX has a very comprehensive Unix API.  Not only it is POSIX
  26. and POSIX-2 compliant, it is also compliant with XOPEN XPG/4,
  27. SVID (SystemV R4), BSD extensions, Unix 95 (Spec 1170) and more.
  28. <p>
  29. Software that compiles on other UNIX'es (notably those
  30. with a smaller API, like Linux and Free/Open/Net BSD),
  31. should, almost with no exceptions, compile and run smoothly
  32. on IRIX.  But read on...
  33. <p>
  34. Still there's way too much software out there that makes non-portable
  35. assumptions or is written improperly, which may cause problems.
  36. <br>
  37.  
  38. <h3>Here's an item list to save you time porting
  39. open source software to IRIX.</h3>
  40. <ul>
  41. <li><a href="#a0">GNU configure and autoconf</a>
  42. <li><a href="#a1">Makefiles</a>
  43. <li><a href="#a2">ranlib</a>
  44. <li><a href="#a3">install</a>
  45. <li><a href="#a4">BSD</a>
  46. <li><a href="#a5">System types</a>
  47. <li><a href="#a6">varargs</a>
  48. <li><a href="#a7">Catching other problems</a>
  49. <li><a href="#a8">SGI cc</a>
  50. <li><a href="#a9">Multiple other problems (too many to list here)</a>
  51. <li><a href="#b0">Build vs. target env</a>
  52. <li><a href="#b1">gcc vs. cc</a>
  53. <li><a href="#b2">portable types</a>
  54. </ul>
  55. <br>
  56. <hr noshade align="center" width="70%">
  57. <br>
  58. <br>
  59. <ul>
  60.  
  61. <p>
  62. <li><b><a name="a0">GNU configure and autoconf</a></b>
  63. <p>
  64.   GNU autoconf generates configure scripts that assume that if a
  65.   library exists, it should be used.  This is incorrect on IRIX, which
  66.   keeps some old libraries around just for the sake of backward
  67.   compatibility with very old programs.  This alone breaks most of the
  68.   GNU utilities on IRIX.  To prevent this from happening, simply force
  69.   GNU configure to explicitly ignore '<code>libsocket</code>',
  70.   '<code>libnsl</code>', '<code>libgen</code>' and '<code>libsun</code>'.
  71.   All these interfaces have their up-to-date entries in the standard C
  72.   library <code>libc.so</code> on IRIX 6.x.
  73. <p>
  74.   For example, when calling GNU configure you should use something like:
  75. <pre>
  76.     ac_cv_lib_gen_getmntent=no \
  77.     ac_cv_lib_sun=no \
  78.         ac_cv_lib_sun_getpwnam=no \
  79.     ac_cv_lib_sun_getmntent=no \
  80.         ac_cv_lib_sun_yp_match=no \
  81.         ac_cv_lib_socket=no \
  82.     ac_cv_lib_socket_main=no \
  83.         configure ...
  84. </pre>
  85.   Note that this is just an example.  Make sure to look at your
  86.   <code>config.cache</code> (or equivalent) file after configuration,
  87.   and inspect it for any suspicious <code>ac_cv_lib...</code> entries
  88.   that match one of the libraries mentioned above and force them to
  89.   <code>no</code> (or equivalent).
  90. </ul>
  91.  
  92. <p>
  93. <ul>
  94. <li><b><a name="a1">Makefiles</a></b>
  95. <p>
  96.   Some open source programs assume GNU make in their Makefiles.  You
  97.   should probably use GNU make on IRIX too.  Compatibility is good.
  98.   With GNU make supporting parallel makes there's really no reason to
  99.   use any IRIX specific make like <code>smake</code>,
  100.   <code>pmake</code>, or <code>make</code>.
  101. <p>
  102.   If you don't have GNU make for IRIX you can download it from <a
  103.   href="http://freeware.sgi.com/">http://freeware.sgi.com/</a> and
  104.   not worry about Makefile portability anymore.
  105.  
  106. <p>
  107. <li><b><a name="a2">ranlib</a></b>
  108. <p>
  109.   This is a historical BSD thing that should have been done
  110.   transparently by the linker.  You don't need to run
  111.   <code>ranlib</code> in IRIX.  If your Makefile calls
  112.   <code>ranlib</code> either delete this or define it to a no-op.
  113. <pre>
  114.     gmake RANLIB=:  ...
  115. </pre>
  116.  
  117.  
  118. <p>
  119. <li><b><a name="a3">install</a></b>
  120. <p>
  121.   The Berkeley '<code>install</code>' is incompatible with the SYSV version.
  122.   Either upgrade to IRIX 6.5 (where the IRIX install has transparent
  123.   BSD compatibility) or define:<pre>
  124.     gmake INSTALL=bsdinst  ...</pre>
  125.  
  126. <p>
  127. <li><b><a name="a4">BSD</a></b>
  128. <p>
  129.   BSD programs that assume a BSD environment should compile
  130.   on IRIX without change (at least in 95% of cases)
  131.   by forcing BSD compatibility via CFLAGS, e.g:<pre>
  132.     gmake CFLAGS="-D_BSD_COMPAT ..."</pre>
  133. <p>
  134.   If you don't want <b><i>full</i></b> BSD compatibility,
  135.   consider using one or more of:<pre>
  136.     -D_BSD_TYPES
  137.     -D_BSD_TIME
  138.     -D_BSD_SIGNALS
  139. </pre>
  140.   <b>Important:</b> if your software is more "properly" written and
  141.   uses POSIX signals (i.e. <code>sigaction</code> instead of
  142.   <code>signal</code>) then you <b>must not</b> compile with
  143.   <code>-D_BSD_SIGNALS</code>.  Mixing signal models may cause
  144.   unpredictable problems.
  145.  
  146. <p>
  147. <li><b><a name="a5">System types</a></b>
  148. <p>
  149.   Some programs assume system types, in particular
  150.   '<code>off_t</code>', are 32 bit (i.e. that files don't exceed 4GB in size)
  151.   These programs are making bad assumptions, but this problem can be
  152.   overcome by compiling in the o32 (cc -32) ABI:<pre>
  153.     gmake CC="cc -32 ..."
  154. </pre>
  155.  
  156. <p>
  157. <li><b><a name="a6">varargs</a></b>
  158. <p>
  159.   Some programs do not comply with the ANSI varargs syntax and conventions
  160.   (i.e. include <code><stdarg.h></code> and use ellipsis
  161.   in the argument list)  
  162.   Again, if those don't work they may start working by compiling
  163.   using the o32 ABI:<pre>
  164.     gmake CC="cc -32 ..."
  165. </pre>
  166.  
  167. <p>
  168. <li><b><a name="a7">Catching other problems</a></b>
  169. <p>
  170.   The SGI <b>cc</b> is verbose and pedantic. The problem is that when
  171.   you get way too many warnings you start ignoring the real ones.
  172. <p>
  173.   To make the SGI compiler more like gcc in terms of warnings you may use
  174.   something like:<pre>
  175.     NOWARN = -woff 1009,1014,1110,1116,1185,1188,1204,1230,1233 \
  176.             -Wl,-woff,85,-woff,84
  177.     $(CC) $(NOWARN) ...</pre>
  178.   In your Makefiles
  179.  
  180.  
  181. <p>
  182. <li><b><a name="a8">SGI cc</a></b>
  183. <p>
  184.   While the SGI cc may look too pedantic, it can catch a lot
  185.   of real source code bugs.  Consider compiling with:<pre>
  186.     CC="cc -fullwarn ..."
  187. </pre>
  188. <p>
  189.   and really clean your source of type mismatches.
  190.  
  191. <p>
  192. <li><b><a name="a9">Multiple other problems (too many to list here)</a></b>
  193. <p>
  194.   Over the years IRIX got thousands of bug fixes.  As expected, problems
  195.   on IRIX 4.0.x are much more numerous than problems on IRIX 6.5.
  196.   If you can upgrade, please do.  <i>Life is way easier with IRIX 6.5.</i>
  197.  
  198.  
  199. <p>
  200. <li><b><a name="b0">Build vs. target env</a></b>
  201. <p>
  202.   Virtually all open source packages assume that the building environment
  203.   is the same as the target environment.  In fact every Makefile with
  204.   a '<code>make install</code>' that directly installs into system directories
  205.   probably makes this assumption.  IRIX supports a much more elegant
  206.   model of 'inst'able packages that can be built anywhere and
  207.   installed anywhere else.
  208. <p>
  209.   It would be nice if there was a UNIX-wide standard for this.  Red Hat
  210.   RPM and other Linux installers are getting there, which is great.
  211. <p>
  212.   We usually build open source software with an IRIX 6.5 ROOT
  213.   (i.e. get include files and libraries from a backward compatible
  214.   6.5 mounted directory).  Assuming this directory is called
  215.   <code>/6.5_root</code> this can be done by:<pre>
  216.     cc -nostdinc -I. -I/6.5_root/usr/include ...    (compiling)
  217.     cc -nostdlib -L/6.5_root/usr/lib32 ...        (linking)
  218. </pre>
  219.  
  220. <p>
  221.   The packaging itself is an art form.  At SGI we use a specialized
  222.   '<code>install</code>' perl script to intercept calls from
  223.   '<code>make install'</code>.  This install adds the appropriate
  224.   lines to the '<code>idb</code>' file instead of actually installing
  225.   files.  Later, this idb file is used by '<code>gendist</code>' to
  226.   create the packages.  Unfortunately, far too many open source
  227.   packages call <code>mv</code>, <code>cp</code>, <code>tar</code>,
  228.   etc. to install, so they bypass this mechanism.  We have considered
  229.   but not yet implemented other solutions, such as trapping system
  230.   calls or running in a <code>chroot</code> directory.  If you find
  231.   (or implement!) a better solution please let us know.
  232.  
  233. <p>
  234. <li><b><a name="b1">gcc vs. cc</a></b>
  235. <p>
  236.   Code that runs fine when compiled with SGI cc and doesn't run
  237.   when compiled with gcc might be calling one of the following functions:<pre>
  238.     inet_ntoa, inet_lnaof, inet_netof, inet_makeaddr, semctl
  239. </pre>
  240.  
  241. <p>
  242.   (there may be others).   These are functions that get passed
  243.   or return structs that are smaller than 16 bytes but not 8 bytes long.
  244.   <i>gcc</i> and <i>SGI cc</i> are incompatible in the way they pass
  245.   these structs so compiling with gcc and linking with the SGI
  246.   <code>libc.so</code> (which was compiled with the <i>SGI cc</i>)
  247.   is likely to cause these problems.
  248.   Note that this problem is pretty rare since such functions are
  249.   not widely used.  This may be considered a bug in <i>gcc</i> but is too
  250.   involved to fix I'm told.
  251.  
  252. <p>
  253. <li><b><a name="b2">portable types</a></b>
  254. <p>
  255.   Occasionally code that works on other platforms will compile fine on
  256.   IRIX, but will misbehave when run.  These problems can be difficult
  257.   to track down, but one thing to check for is assumptions about
  258.   whether <code>char</code> is signed or unsigned.  IRIX compilers
  259.   default to unsigned -- if it matters your code should be explicit!
  260. <p>
  261.   Setting up parallel debugging sessions and stepping through the
  262.   working and non-working code simultaneously to find where they
  263.   diverge is often helpful.
  264.  
  265. </ul>
  266. <center>
  267. <hr noshade width="80%">
  268. Additions and contributions to this list will be gratefully accepted.
  269. <br>
  270. <a href="mailto:freeware@sgi.com">freeware@sgi.com</a>
  271. <hr noshade width="80%">
  272. </center>
  273. <!-- END CONTENTS -->
  274.